package com.zmn.oms.persistence.interfaces.orderattachment;


import com.zmn.oms.model.entity.orderattachment.OrderAttachment;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface OrderAttachmentDao {


    /**
     * 通过主键查询附件信息
     * @param attachmentId
     * @return
     */
    OrderAttachment findAttachmentByKey(Long attachmentId);

    /**
     * 查询该订单下某个附件类型的数量
     *
     * @param orderId
     * @param type
     * @return
     * @author liudi
     * @since: 2022/4/21 14:14
     */
    Integer countByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type);

    /**
     * 描述: 根据订单id和类型查询附件
     *
     * @param orderId 订单id
     * @param type    类型
     * @return {@link List }<{@link OrderAttachment }>
     * @author chengguang
     * @since 2022/06/15
     */
    List<OrderAttachment> listByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type);

    /**
     * 通过工单id查询附件信息
     * @param orderId
     * @return
     */
    List<OrderAttachment> listAttachmentByOrderId(Long orderId);

    /**
     * 根据订单id集合查询附件列表
     *
     * @param orderIdList
     * @return
     */
    List<OrderAttachment> listAttachmentByOrderIdList(@Param("orderIdList") List<Long> orderIdList);

    /**
     * 清除审核相关信息，并更新其他不为null的数据
     * @param attachment
     */
    int updateAttachmentSrcByKey(OrderAttachment attachment);

    /**
     * 批量修改
     * @param attachmentList
     */
    void updateBatch(@Param("attachmentList") List<OrderAttachment> attachmentList);

    /**
     * 修改
     * @param attachment
     */
    int updateByKey(OrderAttachment attachment);

    /**
     * 新增
     * @param orderAttachment
     */
    void insertAttachment(OrderAttachment orderAttachment);

    /**
     * 批量新增
     * @param attachmentList
     */
    void insertAttachmentList(@Param("attachmentList") List<OrderAttachment> attachmentList);

    /**
     * 清除附件信息
     * @param orderId
     */
    void deleteByOrderId(Long orderId);

    /**
     * 通过主键删除
     * @param attachmentId
     */
    void deleteByKey(Long attachmentId);

    /**
     * 批量根据附件ID删除
     *
     * @param attachmentIds
     */
    void deleteBatchByAttachmentIds(@Param("attachmentIds") List<Long> attachmentIds);


}
